#include <iostream>
#include <cstdlib>
#include<ctime>
#include "template_pointerStack.h"
const int NUM = 10;
int main()
{
	int stackSize;

	int nextIn;
	const char * in[NUM] = {
		"1: Hank Gilgamesh", "2: Kiki Ishtar",
		"3: Betty Rocker", "4: Ian Flagranti",
		"5: Wolfgang Kibble", "6: Portia Koop",
		"7: Joy Almondo", "8: Xaverie Paprika",
		"9: Juan Moore", "10: Misha Mache"};

	int processed;
	const char *out[NUM];

	std::cout << "Please enter stack's size (0 to quit): ";
	while (std::cin >> stackSize && stackSize != 0)
	{
		while (std::cin.get() != '\n') {
			continue;
		}
		std::srand(std::time(0));
		nextIn = 0;
		processed = 0;
		Stack<const char *> st(stackSize);
		while (processed < NUM)
		{
			if (st.IsEmpty())
				st.Push(in[nextIn++]);
			else if (st.IsFull())
				st.Pop(out[processed++]);
			else if (std::rand() % 2 && nextIn < NUM)
				st.Push(in[nextIn++]);
			else
				st.Pop(out[processed++]);
		}
		for (int i = 0; i < NUM; i++)
			std::cout << out[i] << std::endl;
		//st.~Stack();    ERROR ! ! !
		std::cout << "Please enter stack's size (0 to quit): ";
	}

	std::cout << "Bye!\n";
	system("pause");
	return 0;
}